package com.easy.dfc.service;

import com.easy.dfc.Utils.PagingUtil;
import com.easy.dfc.mapper.TiantiantejiaMapper;
import com.easy.dfc.entity.Stock;
import com.easy.dfc.entity.TiantiantejiaWithBLOBs;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by VULCANTSeries on 2017/5/16.
 */
@Service
public class TiantiantejiaService {

    @Resource
    private TiantiantejiaMapper tiantiantejiaMapper;

    //根据当前时间选出还在活动时间内的活动
    public List<TiantiantejiaWithBLOBs> getTiantiantejiaList(PagingUtil pagingUtil) {
        List<TiantiantejiaWithBLOBs> tiantiantejiaWithBLOBsList = tiantiantejiaMapper.selectAll(pagingUtil);
        return tiantiantejiaWithBLOBsList;
    }

    //根据传入时间筛选活动
    public List<TiantiantejiaWithBLOBs> getTiantiantejiaInTime(PagingUtil pagingUtil) {
        List<TiantiantejiaWithBLOBs> tiantiantejiaWithBLOBsList = tiantiantejiaMapper.selectInTime(pagingUtil);
        return tiantiantejiaWithBLOBsList;
    }

    //根据BrandId选出还在活动时间内的活动
    public List<TiantiantejiaWithBLOBs> selectByBrandNow(PagingUtil pagingUtil) {
        List<TiantiantejiaWithBLOBs> tiantiantejiaWithBLOBsList = tiantiantejiaMapper.selectByBrandNow(pagingUtil);
        return tiantiantejiaWithBLOBsList;
    }

    //根据BrandId选出往期的活动
    public List<TiantiantejiaWithBLOBs> selectByBrandBefore(PagingUtil pagingUtil) {
        List<TiantiantejiaWithBLOBs> tiantiantejiaWithBLOBsList = tiantiantejiaMapper.selectByBrandBefore(pagingUtil);
        return tiantiantejiaWithBLOBsList;
    }

    //根据FactoryId选出还在活动时间内的活动
    public List<TiantiantejiaWithBLOBs> selectByFactoryNow(PagingUtil pagingUtil) {
        List<TiantiantejiaWithBLOBs> tiantiantejiaWithBLOBsList = tiantiantejiaMapper.selectByFactoryNow(pagingUtil);
        return tiantiantejiaWithBLOBsList;
    }

    //根据FactoryId选出还在活动时间内的活动
    public List<TiantiantejiaWithBLOBs> selectByFactoryNowFor3(PagingUtil pagingUtil) {
        List<TiantiantejiaWithBLOBs> tiantiantejiaWithBLOBsList = tiantiantejiaMapper.selectByFactoryNowFor3(pagingUtil);
        return tiantiantejiaWithBLOBsList;
    }

    //根据productId获取产品信息
    public List<TiantiantejiaWithBLOBs> getTiantiantejia(String ProductId) {
        List<TiantiantejiaWithBLOBs> tiantiantejiaWithBLOBs = tiantiantejiaMapper.selectByProductId(ProductId);
        return tiantiantejiaWithBLOBs;
    }

    //根据ProductId返回库存、
    public Stock stockCheck(String ProductId) {
        Stock stock = tiantiantejiaMapper.stockCheck(ProductId);
        return stock;
    }

    public Stock ValidSales(String ProductId){
        return tiantiantejiaMapper.ValidSales(ProductId);
    }

    //添加新活动
    public int insertSelective(TiantiantejiaWithBLOBs tiantiantejiaWithBLOBs) {
        return tiantiantejiaMapper.insertSelective(tiantiantejiaWithBLOBs);
    }
}
